﻿using Autofac;
using RepositoryAndEf.Core.Common;
using RepositoryAndEf.Core.Common.DependencyManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using RepositoryAndEf.Core.Data;
using RepositoryAndEf.Domain;
using RepositoryAndEf.Data;
using RepositoryAndEf.Service;
using RepositoryAndEf.Infrastructure.Encryption;

namespace RepositoryAndEf.Console
{
    public class DepedencyRegistrar : IDependencyRegistrar
    {
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {

            builder.Register<IUnitOfWork>(c => new RepositoryAndEfContext("ConnStr"));
            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)); ;

            builder.RegisterType<MD5EncryptService>().As<IEncryptionService>();


            builder.RegisterType<ShoppingCartService>().As<IShoppingCartService>();
            builder.RegisterType<OrderService>().As<IOrderService>();
            builder.RegisterType<RepositoryAndEf.Service.UserService>().As<IUserService>();
            builder.RegisterType<OrderFactory>();
            builder.RegisterType<RepositoryAndEf.Domain.UserService>();
        }

        public int Order
        {
            get { return 0; }
        }
    }
}
